//
//  UIBarButtonItem+Extentions.swift
//  swift微博
//
//  Created by qlwl on 17/2/25.
//  Copyright © 2017年 qlwl. All rights reserved.
//

import UIKit

extension UIBarButtonItem {
    
    
    //快捷键 Command + Option + /
    /// 创建UIBarButtonItem
    ///
    /// - Parameters:
    ///   - title: title
    ///   - fontSize: fontSize, 默认16号字
    ///   - targert: taget
    ///   - action: action
    convenience init(title: String ,fontSize:CGFloat = 16,targert: AnyObject?, action: Selector, isBack: Bool = false) {
        let btn: UIButton = UIButton.yw_textButton(title, fontSize: fontSize, normalColor: UIColor.darkGray, highlightedColor: UIColor.orange)
        if isBack {
            let imageName = "navigationbar_back_withtext"
            btn.setImage(UIImage(named: imageName) , for: UIControlState(rawValue: 0))
            btn.setImage(UIImage(named: imageName + "_highlighted")  , for: .highlighted)
        }
        btn.sizeToFit()
        btn.addTarget(targert, action: action, for: .touchUpInside)
        
        self.init(customView:btn)
    }
}
